﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

[CustomEditor(typeof(SmoothPathCurveMesh),true)]
public class SmoothPathCurveMeshEditor : SmoothPathCurveEditor
{
    private SerializedProperty curveRandomRadio;
    private SerializedProperty curveOffsetY;
    private SerializedProperty curveRandomWaveHight;
    private SerializedProperty curveWidthLength;

    protected override void OnEnable()
    {
        base.OnEnable();
        curveRandomRadio = serializedObject.FindProperty("curveRandomRadio");
        curveOffsetY = serializedObject.FindProperty("curveOffsetY");
        curveRandomWaveHight = serializedObject.FindProperty("curveRandomWaveHight");
        curveWidthLength = serializedObject.FindProperty("curveWidthLength");
    }

    public override void OnInspectorGUI()
    {
        EditorGUI.BeginChangeCheck();
        base.OnInspectorGUI();
        SmoothPathCurveMesh meshCurve = this.target as SmoothPathCurveMesh;

        EditorGUILayout.PrefixLabel("曲线波峰");
        EditorGUILayout.PropertyField(curveWidthLength, new GUILayoutOption[0]);
        EditorGUILayout.PropertyField(curveRandomRadio, new GUILayoutOption[0]);
        EditorGUILayout.PropertyField(curveRandomWaveHight, new GUILayoutOption[0]);
        EditorGUILayout.PropertyField(curveOffsetY, new GUILayoutOption[0]);
        if (EditorGUI.EndChangeCheck())
        {
            base.serializedObject.ApplyModifiedProperties();
            meshCurve.CreateCurve();
        }
        //serializedObject.ApplyModifiedProperties();
    }
}
